package com.sfx.mq.producer;

import com.sfx.mq.producer.constants.TopicProperties;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-10-28
 * Time: 18:20
 */
@SpringBootApplication
public class RocketMQProducerApplication implements CommandLineRunner {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication();
        SpringApplication.run(RocketMQProducerApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        // 发送一条同步消息
        rocketMQTemplate.syncSend(TopicProperties.BOOT_CONSUMER_TOPIC,"boot");
        System.out.println("发送了一条消息");
    }
}